<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script type="text/javascript">
    //方法一
    var Animal=new Object();
    Animal.name="北极熊";
    Animal.color="白色";
    Animal.age="1岁";
    Animal.sex="雄性";
    Animal.eat=function(){
        alert("我在吃");
    };

    //方法二
    var Animal={
        name:"北极熊",
        color:"白色",
        age:"1岁",
        sex:"雄性",
        eat:function(){
            alert("我在吃");
        },
    }

    //方法三
    var creatAnimal=function(name,color,age,sex,eat){
        var Animal=new object();
        Animal.name=name;
        Animal.color=color;
        Animal.age=age;
        Animal.sex=sex;
        Animal.eat=function(){
            alert("我在吃");
        };
        return Animal;
    }
    var animal=new Animal("北极熊","白色","1岁","雄性");
    sanimal.eat();

    //方法四
    function Animal(name,color,age,sex){
    this.name=name;
    this.color=color;
    this.age=age;
    this.sex=sex;
    this.eat=function(){
       alert("我在吃");
        };
    };
    var animal=new Animal("北极熊","白色","1岁","雄性");
    animal.eat();
    </script>
</head>
<body>
    
</body>
</html>